package com.atguigu.gulimall.mudan.controller;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.atguigu.gulimall.mudan.entity.SpeciesEntity;
import com.atguigu.gulimall.mudan.service.SpeciesService;
import com.atguigu.common.utils.PageUtils;
import com.atguigu.common.utils.R;



/**
 * 
 *
 * @author yashu
 * @email 2377311752@qq.com
 * @date 2021-06-17 20:31:18
 */
@RestController
@RequestMapping("mudan/species")
public class SpeciesController {
    @Autowired
    private SpeciesService speciesService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("mudan:species:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = speciesService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{peonySpeciesId}")
    //@RequiresPermissions("mudan:species:info")
    public R info(@PathVariable("peonySpeciesId") Integer peonySpeciesId){
		SpeciesEntity species = speciesService.getById(peonySpeciesId);

        return R.ok().put("species", species);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("mudan:species:save")
    public R save(@RequestBody SpeciesEntity species){
		speciesService.save(species);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("mudan:species:update")
    public R update(@RequestBody SpeciesEntity species){
		speciesService.updateById(species);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("mudan:species:delete")
    public R delete(@RequestBody Integer[] peonySpeciesIds){
		speciesService.removeByIds(Arrays.asList(peonySpeciesIds));

        return R.ok();
    }

}
